package com.xuchao.yao_jz.web;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.xuchao.yao_jz.entity.Yaopin;
import com.xuchao.yao_jz.service.IYaopinService;
import com.xuchao.yao_jz.vo.ResultEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mht
 * @since 2020-03-16
 */
@RestController
@RequestMapping("/yaopin")
@Slf4j
public class YaopinController {

    @Autowired
    IYaopinService yaopinService;

    @RequestMapping("/getYaoPinList")
    public ResultEntity getYaoPinList(String yname){
        Wrapper<Yaopin> wrapper = new EntityWrapper();
        if (StringUtils.isNotBlank(yname)){
            wrapper.like("yname",yname);
        }

        List<Yaopin> list = yaopinService.selectList(wrapper);

        return  ResultEntity.ok(list);
    }

}
